<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:c="http://java.sun.com/jsp/jstl/core"
	xmlns:p="http://primefaces.org/ui" >
	    
	<h:form id="frm1">
		<p:growl id="msgs1" showDetail="true" />
		<p:panel id="contPanel" header="订单基本信息" style="margin-bottom:5px">
			
			<h:panelGrid columns="10" cellspacing="10" >								
				<p:outputLabel value="订单编号" />
				<p:inputText  value="#{purchMB.io.id}" required="true" requiredMessage="订单编号必须输入"/>
				<p:outputLabel value="下单日期" />
				<p:calendar id="signDate" locale="zh" navigator="true"  value="#{purchMB.io.orderDate}" 
					pattern="yyyy-MM-dd" mask="true"  mode="popup"	showOn="button" popupIconOnly="true"
					required="true" requiredMessage="订单日期必须输入" />

				<p:outputLabel value="合同选择" />
				<p:selectOneMenu value="#{purchMB.selectedContract}" converter="bmeContractConverter" 
						effect="fade"  style="width:80%" panelStyle="width:180px" 
                        var="t" filter="true" filterMatchMode="startsWith"
                        required="true" requiredMessage="合同名称必须输入" >
                    <p:ajax listener="#{purchMB.onSelectedContract}" update=":frm1:pcontract :frm1:pproject" />     
		            <f:selectItems value="#{purchMB.bmeContracts}" var="scontrtacr" itemLabel="#{scontrtacr.id}" itemValue="#{scontrtacr}" />
		 
		            <p:column style="width:10%">
		                <h:outputText value="#{t.id}" />
		            </p:column>		 
		            <p:column>
		                <h:outputText value="#{t.name}" />
		            </p:column>        
		        </p:selectOneMenu>
				<p:outputLabel value="合同名称" />
				<p:inputText id="pcontract" value="#{purchMB.selectedContract.name}"  readonly="true"  disabled="true"/>
				<p:outputLabel value="项目名称" />
				<p:inputText id="pproject" value="#{purchMB.selectedContract.pname}"  readonly="true"  disabled="true"/>
				
				<p:outputLabel value="供应商选择" />
				<p:selectOneMenu value="#{purchMB.selectedSupplier}" converter="bmeSupplierConverter" 
						effect="fade"  style="width:80%" panelStyle="width:180px" 
                        var="t" filter="true" filterMatchMode="startsWith"
                        required="true" requiredMessage="供应商ID必须输入" >
                    <p:ajax update=":frm1:psupplier " />     
		            <f:selectItems value="#{purchMB.bmeSuppliers}" var="ssupplier" itemLabel="#{ssupplier.id}" itemValue="#{ssupplier}" />
		 
		            <p:column style="width:10%">
		                <h:outputText value="#{t.id}" />
		            </p:column>		 
		            <p:column>
		                <h:outputText value="#{t.name}" />
		            </p:column>        
		        </p:selectOneMenu>
        
				<p:outputLabel value="供应商名称" />
				<p:inputText id="psupplier" value="#{purchMB.selectedSupplier.name}"  disabled="true"/>

				<p:outputLabel value="收货地址" />
				<p:inputText value="#{purchMB.io.shippingAddress}" />	
				<p:outputLabel value="收货人" />
				<p:inputText value="#{purchMB.io.consignee}" />	
				<p:outputLabel value="电话" />
				<p:inputText value="#{purchMB.io.phone}" />	
				
				<p:outputLabel value="订单状态" />
				<p:selectOneMenu value="#{purchMB.io.status}" effect="fold" style="width:80%;" 
					required="true" requiredMessage="状态必须输入" >
					<f:selectItems value="#{purchMB.itemsPurchStatus}" />
				</p:selectOneMenu>					
				<p:outputLabel value="备注" />
				<p:inputText value="#{purchMB.io.remarks}" />	
				<p:outputLabel value="订单金额" />
				<p:inputText id="pOrderAmount" value="#{purchMB.io.amount}"  disabled="true"/>	
									
			</h:panelGrid>
				
		</p:panel>
		
	</h:form>
	<h:form id="frmAttach" > 	
		<p:panel id="panelAttach" header="附件信息上传" style="margin-bottom:5px" rendered="#{purchMB.uploadFlag}">	
			<!-- 页面间参数传递 -->
			<ui:include src="bme_attach_upload.xhtml">
			     <ui:param name="uploadForType" value="#{purchMB.uploadForType}" />
			     <ui:param name="uploadForId" value="#{purchMB.uploadForId}" />
			     <ui:param name="uploadForName" value="#{purchMB.uploadForName}" />
			</ui:include>		
		</p:panel>
	</h:form>
	
		<h:form id="frm2">	
		<p:growl id="msgs2" showDetail="true" />
		<p:panel id="prodPanel" header="订单采购信息" style="margin-bottom:5px">
     	    		
			<p:dataTable id="rdt" value="#{purchMB.vod}"  var="row"  rowIndexVar="rowNum"
				resizableColumns="true" liveResize="true" 
				scrollable="true" scrollWidth="98%" 
				editable="true"  style="margin-bottom:5px"
				paginator="true" paginatorPosition="bottom" rows="8" 
				emptyMessage="没有记录" >

				<p:ajax event="rowEdit" listener="#{purchMB.onRowEdit}"
					update=":frm2:msgs2" />
				<p:ajax event="rowEditCancel"	listener="#{purchMB.onRowCancel}"
					update=":frm2:msgs2" />
				
								
				<p:column headerText="修改" style="width:32px">
					<p:rowEditor editTitle="修改" cancelTitle="取消" saveTitle="保存"/>
				</p:column>
					
				<p:column headerText="No." width="20" >
					#{rowNum+1}
				</p:column>
				<p:column headerText="反馈交期" width="100" >
					<p:cellEditor>
						<f:facet name="output">
							<h:outputText value="#{row.respDate}" >
								<f:convertDateTime pattern="yyyy-MM-dd" timeZone="GMT+8"/>
							</h:outputText>						
						</f:facet>
						<f:facet name="input">
							<p:inputText value="#{row.respDate}" >
								<f:convertDateTime pattern="yyyy-MM-dd" timeZone="GMT+8"/>
							</p:inputText>
						</f:facet>
					</p:cellEditor>
				</p:column>				
				<p:column headerText="反馈备注" width="100" >
					<p:cellEditor>
						<f:facet name="output">	<h:outputText value="#{row.respRemarks}" /></f:facet>
						<f:facet name="input">	<p:inputText value="#{row.respRemarks}" /></f:facet>
					</p:cellEditor>
				</p:column>									
				
				<p:column headerText="物料编号" sortBy="#{row.bmeMaterial.id}" width="100" >
					<h:outputText value="#{row.bmeMaterial.id}" />
				</p:column>
				<p:column headerText="物料描述" width="100" >
					<h:outputText value="#{row.bmeMaterial.mdesc}" />
				</p:column>
				<p:column headerText="数量" width="100" >
					<p:cellEditor>
						<f:facet name="output"><h:outputText value="#{row.mquantity}" /></f:facet>
						<f:facet name="input"><p:inputText value="#{row.mquantity}"  /></f:facet>
					</p:cellEditor>
				</p:column>

				<p:column headerText="单价" width="100" >
					<p:cellEditor>
						<f:facet name="output"><h:outputText value="#{row.mprice}" /></f:facet>
						<f:facet name="input"><p:inputText value="#{row.mprice}" /></f:facet>
					</p:cellEditor>
				</p:column>
				<p:column headerText="金额" width="100" >
					<p:cellEditor>
						<f:facet name="output"><h:outputText value="#{row.mamount}" /></f:facet>
						<f:facet name="input"><p:inputText value="#{row.mamount}" />
						</f:facet>
					</p:cellEditor>
				</p:column>
				<p:column headerText="总金额" width="100" >
					<p:cellEditor>
						<f:facet name="output">	<h:outputText value="#{row.amount}" /></f:facet>
						<f:facet name="input">	<p:inputText value="#{row.amount}" /></f:facet>
					</p:cellEditor>
				</p:column>	
				<p:column headerText="要求交期" width="100" >
					<p:cellEditor>
						<f:facet name="output">
							<h:outputText value="#{row.requiredDate}" >
								<f:convertDateTime pattern="yyyy-MM-dd"  timeZone="GMT+8"/>
							</h:outputText>						
						</f:facet>
						<f:facet name="input">
							<p:inputText value="#{row.requiredDate}" >
								<f:convertDateTime pattern="yyyy-MM-dd" timeZone="GMT+8"/>
							</p:inputText>
						</f:facet>
					</p:cellEditor>
				</p:column>

				<p:column headerText="安装区域" width="100" >
					<p:cellEditor>
						<f:facet name="output"><h:outputText value="#{row.area}" /></f:facet>
						<f:facet name="input"><p:inputText value="#{row.area}" /></f:facet>
					</p:cellEditor>
				</p:column>
				<p:column headerText="备注" width="100" >
					<p:cellEditor>
						<f:facet name="output"><h:outputText value="#{row.remarks}" /></f:facet>
						<f:facet name="input"><p:inputText value="#{row.remarks}" />
						</f:facet>
					</p:cellEditor>
				</p:column>

				<p:column headerText="加工工艺" width="100" >
					<p:cellEditor>
						<f:facet name="output">	<h:outputText value="#{row.processTeck}" /></f:facet>
						<f:facet name="input">	<p:inputText value="#{row.processTeck}" /></f:facet>
					</p:cellEditor>
				</p:column>					
				<p:column headerText="加工色号" width="100" >
					<p:cellEditor>
						<f:facet name="output">	<h:outputText value="#{row.processColor}" /></f:facet>
						<f:facet name="input">	<p:inputText value="#{row.processColor}" /></f:facet>
					</p:cellEditor>
				</p:column>				
				
				<p:column headerText="加工规格" width="100" >
					<p:cellEditor>
						<f:facet name="output">	<h:outputText value="#{row.processSpeci}" /></f:facet>
						<f:facet name="input">	<p:inputText value="#{row.processSpeci}" /></f:facet>
					</p:cellEditor>
				</p:column>					
				<p:column headerText="每片加工量" width="100" >
					<p:cellEditor>
						<f:facet name="output">	<h:outputText value="#{row.processFactor}" /></f:facet>
						<f:facet name="input">	<p:inputText value="#{row.processFactor}" /></f:facet>
					</p:cellEditor>
				</p:column>					
				<p:column headerText="加工总量" width="100" >
					<p:cellEditor>
						<f:facet name="output">	<h:outputText value="#{row.processSum}" /></f:facet>
						<f:facet name="input">	<p:inputText value="#{row.processSum}" /></f:facet>
					</p:cellEditor>
				</p:column>					
				<p:column headerText="数量-片" width="100" >
					<p:cellEditor>
						<f:facet name="output">	<h:outputText value="#{row.processQuantity}" /></f:facet>
						<f:facet name="input">	<p:inputText value="#{row.processQuantity}" /></f:facet>
					</p:cellEditor>
				</p:column>	
				<p:column headerText="加工单价" width="100" >
					<p:cellEditor>
						<f:facet name="output">	<h:outputText value="#{row.processPrice}" /></f:facet>
						<f:facet name="input">	<p:inputText value="#{row.processPrice}" /></f:facet>
					</p:cellEditor>
				</p:column>					
				<p:column headerText="加工单位" width="100" >
					<p:cellEditor>
						<f:facet name="output">	<h:outputText value="#{row.processUnit}" /></f:facet>
						<f:facet name="input">	<p:inputText value="#{row.processUnit}" /></f:facet>
					</p:cellEditor>
				</p:column>	
				<p:column headerText="加工费用" width="100" >
					<p:cellEditor>
						<f:facet name="output">	<h:outputText value="#{row.processAmount}" /></f:facet>
						<f:facet name="input">	<p:inputText value="#{row.processAmount}" /></f:facet>
					</p:cellEditor>
				</p:column>					
				
			</p:dataTable>
    
		</p:panel>
		
	</h:form>
    
</ui:composition>
